﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Duisho d = new Duisho();//对手
            Wanjia w = new Wanjia();//玩家
            PK p = new PK();//PK
            Console.WriteLine("----------欢迎进入游戏世界----------");
            Console.WriteLine("----------猜拳        开始----------");
            Console.WriteLine("出拳规则：1.剪刀，2.石头，3.布");
            while (true)
            {
                d.Mingzi();
                w.Mingzi();
                Console.WriteLine("{0} vs {1}", w.Name, d.Name);
                Console.WriteLine("开始游戏吗？《y/n》");
                string b = Console.ReadLine();
                bool F = true;
                switch (b)
                {
                    case "y":
                        p.Wjuedou();
                        p.Djuedou();
                        Console.WriteLine("{0}：出拳：{1}", w.Name, p.Wchu);
                        Console.WriteLine("{0}：出拳：{1}", d.Name, p.Dchu);
                        p.panding();
                        while (F)
                        {
                            int index = 0;
                            index++;
                            Console.WriteLine("是否开始下一轮？《y/n》");
                            string e = Console.ReadLine();
                            switch (e)
                            {
                                case "y":
                                    p.Wjuedou();
                                    p.Djuedou();
                                    Console.WriteLine("{0}：出拳：{1}", w.Name, p.Wchu);
                                    Console.WriteLine("{0}：出拳：{1}", d.Name, p.Dchu);
                                    p.panding();
                                    break;
                                case "n":
                                    Console.WriteLine("-------------------------");
                                    Console.WriteLine("{0} vs {1}", w.Name, d.Name);
                                    Console.WriteLine("对战次数{0}", index);
                                    Console.WriteLine("姓名\t得分");
                                    Console.WriteLine("{0}\t{1}", w.Name, p.Ying);
                                    Console.WriteLine("{0}\t{1}", d.Name, p.Shu);
                                    if (p.Ying > p.Shu)
                                    {
                                        Console.WriteLine("结果：{0}赢了，{1}笨蛋", w.Name, d.Name);
                                    }
                                    else if (p.Ying == p.Shu)
                                    {
                                        Console.WriteLine("结果：{0}与{1}和局", w.Name, d.Name);
                                    }
                                    else if (p.Ying < p.Shu)
                                    {
                                        Console.WriteLine("结果：{0}赢了，{1}笨蛋", d.Name, w.Name);
                                    }
                                    F = false;
                                    break;
                            }
                        }


                        break;
                    case "n":
                        Console.WriteLine("程序结束");
                        break;
                }
                Console.WriteLine("要开始下一局？ Y/N");
                string t = Console.ReadLine();
                if (t=="y")
                {
                    continue;
                }
                else if(t=="n")
                {
                    Console.WriteLine("程序结束");
                    break;
                }
            }
            Console.ReadKey();

        }
    }
}
